/*
2019.9.20
*/
#include<iostream>
#include<string>
using std::cout;
using std::cin;
using std::endl;
using std::string;

class Solution {
public:
    static bool isPalindrome(string s) 
	{
        if(s.size()==0)
        {
        	return true;
		}
		
		for(int i=0,j=s.size()-1;i<j;i++,j--)
		{
			while(!isEffect(s[i])&&i<j)
			{
				i++;
			}
			while(!isEffect(s[j])&&i<j)
			{
				j--;
			}
			
			if( i<j&&!isMatch( s[i],s[j] )   )
			{
				return false;
			}
		}
		return true;
    }
    
    static bool isMatch(char a,char b)
    {
    	if(a==b)
    	{
    		return true;
		}
		if(a>='a'&&a<='z'&&a-b==32)
		{
			return true;
		}
		if(b>='a'&&b<='z'&&b-a==32)
		{
			return true;
		}
		
		return false;
	}
	
	
	static bool isEffect(char a)
	{
		if(a<='z'&&a>='a'||a<='Z'&&a>='A'||a>='0'&&a<='9')
		{
			return true;
		}
		return false;
	}
};
int main()
{
	Solution solution;
	string s="A man, a plan, a canal: Panama";
	cout<<solution.isPalindrome(s)<<endl;
	return 0;
}
